package com.cn.serverline.lineicp.productionLine.controller;

import cn.hutool.core.lang.tree.Tree;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import javax.annotation.Resource;
import javax.validation.Valid;

import com.cn.serverline.lineicp.productionLine.param.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import com.cn.serverline.lineicp.productionLine.entity.ProductMix;
import com.cn.serverline.lineicp.productionLine.service.IProductMixService;
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


/**
 * 产品结构 接口
 *
 * @author Gmr
 * @since 2024-07-30
 */
@RestController
@Api(tags = "产品结构")
@ApiResource(name = "产品结构的接口")
@Validated
public class ProductMixController {

    @Resource(name = "ProductMixServiceImpl")
    private IProductMixService iProductMixService;

    /**
     * 添加产品类型和产品型号
     */
    @ApiOperation(value = "添加产品类型和产品型号")
    @PostResource(name = "添加产品类型和产品型号", path = "/productionLine/productMix/addProducts")
    public ResponseData<?> addProducts(@RequestBody @Valid ProductsAddParam productMix){
        iProductMixService.addProducts(productMix);
        return new SuccessResponseData<>();
    }

    /**
     * 添加零组件
     */
    @ApiOperation(value = "添加零组件")
    @PostResource(name = "添加零组件", path = "/productionLine/productMix/addProcessScheme")
    public ResponseData<ProductMix> addProcessScheme(@RequestBody @Valid ProcessSchemeAddParam productMix){
        iProductMixService.addProcessScheme(productMix);
        return new SuccessResponseData<>();
    }

    /**
     * 删除产品结构
     */
    @ApiOperation(value = "删除产品结构")
    @PostResource(name = "删除产品结构", path = "/productionLine/productMix/delete")
    public ResponseData<?> delete(@RequestBody @Valid ProductMixIdParam productMix){
        iProductMixService.del(productMix);
        return new SuccessResponseData<>();
    }

    /**
     * 编辑产品类型和产品型号
     */
    @ApiOperation(value = "编辑产品类型和产品型号")
    @PostResource(name = "编辑产品类型和产品型号", path = "/productionLine/productMix/editProducts")
    public ResponseData<?> editProducts(@RequestBody @Valid ProductsEditParam productMix) {
        iProductMixService.editProducts(productMix);
        return new SuccessResponseData<>();
    }

    /**
     * 编辑零组件
     */
    @ApiOperation(value = "编辑零组件")
    @PostResource(name = "编辑零组件", path = "/productionLine/productMix/editProcessScheme")
    public ResponseData<?> editProcessScheme(@RequestBody @Valid ProcessSchemeEditParam productMix) {
        iProductMixService.editProcessScheme(productMix);
        return new SuccessResponseData<>();
    }

    /**
     * 获取树结构
     */
    @ApiOperation(value = "获取树结构")
    @PostResource(name = "分页查询-产品结构列表", path = "/productionLine/productMix/tree")
    public ResponseData<List<Tree<Long>>> tree(@RequestBody @Valid ProductMixTreeParam productMix) {
        return new SuccessResponseData<>(iProductMixService.tree(productMix));
    }

    /**
     * 获取型号列表
     */
    @ApiOperation(value = "获取型号列表")
    @GetResource(name = "获取型号列表", path = "/productionLine/productMix/listModel")
    public ResponseData<List<ProductMix>> listModel() {
        return new SuccessResponseData<>(iProductMixService.listModel());
    }

    /**
     * 获取产品结构详情
     */
    @ApiOperation(value = "获取产品结构详情")
    @PostResource(name = "获取产品结构详情", path = "/productionLine/productMix/detail")
    public ResponseData<ProductMix> detail(@RequestBody @Valid ProductMixIdParam productMix) {
        return new SuccessResponseData<>(iProductMixService.detail(productMix));
    }
}
